<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="${objName}Mapper">
	
	<!-- 通过ID获取数据 -->
	<select id="findById" parameterType="pd" resultType="pd">
		SELECT 
			*
		FROM
			${tableName}
		WHERE 
			id = ${r"#{"}id${r"}"}
	</select>

	<!-- 新增数据 -->
	<insert id="save" parameterType="pd">
		INSERT INTO ${tableName}(
		<#list fieldList as var>  
			${var[0]}<#if var_has_next>,</#if>
		</#list>
		) VALUES (
		<#list fieldList as var>
			${r"#{"}${var[0]}${r"}"}<#if var_has_next>,</#if>
		</#list>
		)
	</insert>
	
	
	<!-- 更新数据 -->
	<update id="update" parameterType="pd">
		UPDATE ${tableName}
		SET
		<#list fieldList as var>  
			${var[0]} = ${r"#{"}${var[0]}${r"}"}<#if var_has_next>,</#if>
		</#list>
		WHERE
			id = ${r"#{"}id${r"}"}
	</update>
	
	<!-- 删除数据 -->
	<delete id="delete" parameterType="pd">
		DELETE FROM 
			${tableName}
		WHERE
			id = ${r"#{"}id${r"}"}
	</delete>
	
	<!-- 列表 -->
	<select id="dataListPage" parameterType="page" resultType="pd">
		SELECT 
			*
		FROM 
			${tableName}
	</select>
	
	<!-- 获取所有${objName}数据 -->
	<select id="listAll" parameterType="pd" resultType="pd">
		SELECT 
			*
		FROM 
			${tableName}
	</select>
	
	<!-- 批量删除 -->
	<delete id="deleteAll" parameterType="String">
		DELETE FROM 
			${tableName}
		WHERE 
			id in
		<foreach item="item" index="index" collection="array" open="(" separator="," close=")">
                 ${r"#{item}"}
		</foreach>
	</delete>
	
	
	
	
</mapper>